package com.example.order.controller;

import com.example.common.api.ResultUtil;
import com.example.order.service.ICartService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

/**
 * 购物车
 * */
@RestController
@RequestMapping("/api/cart")
@Slf4j
@Validated
public class CartController {

    @Resource
    private ICartService cartService;

    /**
     * 通过用户ID获取购物车信息
     * */
    @RequestMapping(value = "/get_cart_by_id", method = RequestMethod.POST)
    @ResponseBody
    public Mono<ResultUtil> getCartById(){
        return cartService.getCartById();
    }

    /**
     * 通过用户ID获取购物车信息
     * */
    @RequestMapping(value = "/get_cart_by_page", method = RequestMethod.POST)
    @ResponseBody
    public Mono<ResultUtil> getCartByPage(@RequestParam int pageIndex,
                                        @RequestParam int pageSize){
        return cartService.getCartByPage(pageIndex, pageSize);
    }
}
